package iterator;

public class ConcreteAggregate implements Aggregate {

    private Object[] objs;

    private int size = 0;

    public ConcreteAggregate() {
        objs = new Object[10];
    }

    public ConcreteAggregate(int capacity) {
        objs = new Object[capacity];
    }

    @Override
    public Iterator createIterator() {
        return new ConcreteIterator(this);
    }

    @Override
    public void add(Object object) {
        objs[size++] = object;
    }

    @Override
    public Object get(int i) {
        return objs[i];
    }

    @Override
    public int size() {
        return size + 1;
    }
}
